package com.unionx.unionxuf.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.unionx.unionxuf.entity.BillSub;
import com.unionx.unionxuf.entity.BillSubInfoDTD;
import com.unionx.unionxuf.entity.CropDTD;
import com.unionx.unionxuf.localdao.BillSubMapper;


@Service("BillSubService")
public class BillSubserviceImpl implements BillSubService {
	@Autowired(required=true)
	private BillSubMapper bsm;

	@Override
	public int insertBs(BillSub billSub) {
		// TODO Auto-generated method stub
		return bsm.insert(billSub);
	}

	@Override
	public int updateBs(BillSub billSub) {
		// TODO Auto-generated method stub
		return bsm.updateByPrimaryKey(billSub);
	}

	@Override
	public List<BillSub> selectAll(String cropid) {
		// TODO Auto-generated method stub
		return bsm.selectAll(cropid);
	}

	@Override
	public Object getBillSub(String cropid, String serialno) {
		// TODO Auto-generated method stub
		CropDTD  c = new CropDTD();
		c.setCorpid(cropid);
		c.setIsno(serialno);
		
		List<BillSubInfoDTD> bblist = new ArrayList<BillSubInfoDTD>();
		List<BillSub> blist =bsm.selectBillSub(c);
		
		for(int i=0;i<blist.size();i++){
			
			BillSubInfoDTD bb = new BillSubInfoDTD();
			bb.setConsultationFied(blist.get(i).getXczx());
			bb.setConsultationTel(blist.get(i).getPhonezx());
			bb.setConsultationSite(blist.get(i).getWebzx());
			bb.setMarkingdepa(blist.get(i).getScb());
			bb.setOutpatientNurse(blist.get(i).getMenzhen());
			bb.setOtherDepa(blist.get(i).getOtherpp());
			bb.setHydw(blist.get(i).getHydw());
			bb.setChuku(blist.get(i).getChuku());
			bblist.add(bb);
		}
		
		return bblist;
	}
}
